<extend name="Public:index" />
<block name="title">
	<title>角色功能代码管理</title>
</block>
<block name="mycss">
	<style type="text/css">
		.tip {
			width: 280px;
			padding: 10px;
			text-align: center;
			background-color: #5cb85c;
			color: #fff;
			position: fixed;
			top: 10px;
			left: 50%;
			z-index: 100001;
			margin-left: -150px;
			box-shadow: 1px 1px 5px #333;
			-webkit-box-shadow: 1px 1px 5px #333;
		}

		.inputx {
			width: 100%;
		}
	</style>
</block>
<block name="main-crumb">
	<li class="active">角色功能代码管理</li>
</block>
<block name="main-content">
	<div class="page-content">
		<div class="container-fluid">
			<div class="row">
				<div class="col-12">
					<div class="card">
						<div class="card-body">
							<iframe name="ajaxifr" style="display:none;"></iframe>
							<div class="btn-group m10" role="group" aria-label="...">
								<a class="btn btn-sm btn_primary" data-toggle="modal" data-target="#editModal" href="{:U('editCode')}">
									<i class="ace-icon fa fa-plus"></i> 添加功能代码
								</a>
							</div>

							<table class="table table-bordered table-striped table-hover m_table_miw">
								<thead class="thin-border-bottom">
									<tr>
										<th>选择</th>
										<th>代码</th>
										<th>功能名称</th>
										<th>描述</th>
									</tr>
								</thead>
								<tbody>
									<volist name="list" id="vo" empty="$empty">
										<tr>
											<td width="5%">
												<label>
													<input class="ace del" type="checkbox" value="{$vo.id}">
													<span class="lbl"></span>
												</label>
											</td>
											<td><a href="{:U('editCode',array('id'=>$vo['id']))}" data-toggle="modal" data-target="#editModal"
												 data-backdrop="static" title="{$vo.code}">{$vo.code}</a></td>
											<td>{$vo.name}</td>
											<td>{$vo.intro}</td>
										</tr>
									</volist>
									<tr>
										<td colspan="4"><button type="button" class="btn btn-danger btn-sm" id="delbtn"><i class="ace-icon fa fa-trash"></i>
												删除</button></td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editChart">
							<form id="frm2" action="{:U('editCode')}" method="post" target="ajaxifr">
								<div class="modal-dialog" role="document">
									<div class="modal-content">

									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="myscript">
	<script>
		$(function () {
			$('#editModal').on('hidden.bs.modal', function () {
				$(this).removeData("bs.modal");
			});

			$('#delbtn').on('click', function () {
				var url = "{:U('delCode')}";
				var ids = [];
				$('.del:checked').each(function () {
					ids.push($(this).val());
				});
				if (ids.length > 0) {
					var queren = prompt("确定删除选择的功能代码吗？输入yes确认删除！");
					if ($.trim(queren) == "yes") {
						$.post(url, { ids: ids }, function (res) {
							if (res == '1') {
								window.location.reload();
							}
						});
					}
				}
			});
		});
		//消息通知
		function notify(msg, func) {
			$("<div>")
				.appendTo(document.body)
				.text(msg)
				.addClass("tip")
				.position({
					my: "center top",
					at: "center top",
					of: window
				})
				.show({
					effect: "blind"
				})
				.delay(1500)
				.hide({
					//effect: "blind",
					duration: "slow",
					complete: function () {
						$(this).remove();
						if (typeof func != "undefined")
							func.call();
					}
				});
		}
	</script>
</block>